package com.craney.testTextField
{
	import flash.display.Sprite;
	import flash.text.StyleSheet;
	import flash.text.TextField;
	import flash.text.TextFormat;
	
	public class TestStyleSheet
	{
		private var parentSprite:Sprite;
		
		private var tf:TextField = new TextField();
		
		public function TestStyleSheet(ps:Sprite)
		{
			parentSprite = ps;
			
			tf.border = true;
			
			var formate1:TextFormat = new TextFormat();
			formate1.color = 0x00ff00;
			
			//先声明一个CSS
			var css:StyleSheet = new StyleSheet();
			//再声明一个存储CSS样式内容的Object
			var cssObj:Object = {fontSize:"bold", color:"#FF0000"};
			//将上面Object加入CSS对象中
			css.setStyle(".darkRed", cssObj);
			//将CSS应用于TextField	
			tf.styleSheet = css;



			
			tf.htmlText = "<span class='darkRed'>Red</span>  apple";
//			tf.text = "Green  apple text";
			
//			tf.setTextFormat(formate1);
			
			trace(tf.htmlText);
			trace(tf.text);
			
			tf.styleSheet = null;
			
			trace(tf.htmlText);
			trace(tf.text);
				
				
			parentSprite.addChild(tf);	
		}

	}
}